package com.hopu.haogoumall.db.mapper;

import com.hopu.haogoumall.db.module.HaogoumallKeyword;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface HaogoumallKeywordMapper {
    @Delete({
        "delete from haogoumall_keyword",
        "where keyword_id = #{keywordId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer keywordId);

    @Insert({
        "insert into haogoumall_keyword (keyword_id, keyword, ",
        "keyword_url, keyword_is_hot, ",
        "keyword_is_default, keyword_sort_order, ",
        "keyword_add_time, keyword_update_time, ",
        "keyword_deleted)",
        "values (#{keywordId,jdbcType=INTEGER}, #{keyword,jdbcType=VARCHAR}, ",
        "#{keywordUrl,jdbcType=VARCHAR}, #{keywordIsHot,jdbcType=BIT}, ",
        "#{keywordIsDefault,jdbcType=BIT}, #{keywordSortOrder,jdbcType=INTEGER}, ",
        "#{keywordAddTime,jdbcType=TIMESTAMP}, #{keywordUpdateTime,jdbcType=TIMESTAMP}, ",
        "#{keywordDeleted,jdbcType=BIT})"
    })
    int insert(HaogoumallKeyword record);

    @InsertProvider(type=HaogoumallKeywordSqlProvider.class, method="insertSelective")
    int insertSelective(HaogoumallKeyword record);

    @Select({
        "select",
        "keyword_id, keyword, keyword_url, keyword_is_hot, keyword_is_default, keyword_sort_order, ",
        "keyword_add_time, keyword_update_time, keyword_deleted",
        "from haogoumall_keyword",
        "where keyword_id = #{keywordId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="keyword_id", property="keywordId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="keyword", property="keyword", jdbcType=JdbcType.VARCHAR),
        @Result(column="keyword_url", property="keywordUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="keyword_is_hot", property="keywordIsHot", jdbcType=JdbcType.BIT),
        @Result(column="keyword_is_default", property="keywordIsDefault", jdbcType=JdbcType.BIT),
        @Result(column="keyword_sort_order", property="keywordSortOrder", jdbcType=JdbcType.INTEGER),
        @Result(column="keyword_add_time", property="keywordAddTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="keyword_update_time", property="keywordUpdateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="keyword_deleted", property="keywordDeleted", jdbcType=JdbcType.BIT)
    })
    HaogoumallKeyword selectByPrimaryKey(Integer keywordId);

    @UpdateProvider(type=HaogoumallKeywordSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(HaogoumallKeyword record);

    @Update({
        "update haogoumall_keyword",
        "set keyword = #{keyword,jdbcType=VARCHAR},",
          "keyword_url = #{keywordUrl,jdbcType=VARCHAR},",
          "keyword_is_hot = #{keywordIsHot,jdbcType=BIT},",
          "keyword_is_default = #{keywordIsDefault,jdbcType=BIT},",
          "keyword_sort_order = #{keywordSortOrder,jdbcType=INTEGER},",
          "keyword_add_time = #{keywordAddTime,jdbcType=TIMESTAMP},",
          "keyword_update_time = #{keywordUpdateTime,jdbcType=TIMESTAMP},",
          "keyword_deleted = #{keywordDeleted,jdbcType=BIT}",
        "where keyword_id = #{keywordId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(HaogoumallKeyword record);
}